import { IDevice, DeviceInfo, HostInfo } from "../IDevice";

export class WXDevice extends IDevice{
    protected _wx:any;
    init(type: string): IDevice {
        this._wx = window['wx'];
        return super.init(type);
    }
    
    vibrate(long: boolean): void {
        if(!this.vibrateAble){
            return;
        }
        long ? this._wx.vibrateLong({}) : this._wx.vibrateShort({});
    }

    get deviceInfo():DeviceInfo {
        let deviceInfo = this._wx.getDeviceInfo();
        return {
            brand: deviceInfo.brand,
            system: deviceInfo.system,
            model: deviceInfo.model,
            platform: deviceInfo.platform
        }
    }

    get hostInfo():HostInfo {
        let hostInfo = this._wx.getAppBaseInfo();
        return {
            name: "微信",
            version: hostInfo.version
        }
    }
}
